import router from "./index.js";
import store from "@/store/index.js";

const whiteList = ["/login", "/about"];
router.beforeEach((to, from, next) => {
  if (store.getters.getToken) {
    if (to.path === "/login") {
      console.log("已经登录了");
      next("/");
    } else {
      next();
    }
  } else {
    if (whiteList.includes(to.path)) {
      next();
    } else {
      next("/login");
    }
  }
});
